﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.DisplayManagement.Descriptors;
using Orchard;
using Orchard.Environment.Extensions;

namespace RaisingStudio.Razor.Providers
{
    [OrchardFeature("RaisingStudio.Razor.Services.RazorAlternate")]
    public class RazorShapeProvider : IShapeTableProvider
    {
        private readonly IWorkContextAccessor _workContextAccessor;

        public RazorShapeProvider(IWorkContextAccessor workContextAccessor)
        {
            _workContextAccessor = workContextAccessor;
        }

        public void Discover(ShapeTableBuilder builder)
        {
            builder.Describe("Parts_Common_Body")
                .OnDisplaying(displaying =>
                {
                    if (displaying.ShapeMetadata.DisplayType == "Detail")
                    {
                        displaying.ShapeMetadata.Alternates.Add("RazorAlternateBody");
                    }
                });
        }
    }
}